package com.jotal.api.response;

import java.io.Serializable;

/**
 * @description:
 * @author: Jotal
 * @time: 2021/1/22 15:15
 */
public class BaseResult<T> implements Serializable {

//    响应编码
    private Integer code;
    //响应消息
    private String msg;
    //响应数据
    private T data;

    private static final BaseResult SUCCESS = sud();
    private static final BaseResult FAIL = fail();


    private static BaseResult fail(){
        BaseResult result = new BaseResult();
        result.setMsg("error");
        return result;
    }
    private static BaseResult sud(){
        BaseResult result = new BaseResult();
        result.setMsg("success");
        return result;
    }

    public BaseResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public BaseResult(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public BaseResult() {
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
